/**
 * ҳ�����top��ť
 */
function autoTop() {
    'use strict';
    var cont = $('.container:eq(0)'),
        left = cont.offset().left + cont.width()+5,
        $btnTop =  null,
        clientHeight = document.documentElement.clientHeight,
    $topHtml =$('<div class="btn-top">\
                            <a href="javascript:void 0;"><i class="icon-p icon-top"></i></a>\
                    </div>');
    $('body').append($topHtml);
    $btnTop =  $('.btn-top')
    $btnTop.css({
        left:left
    });

    $(window).on('scroll', function () {
        var $window = $(window);
        if($window.scrollTop() < 300){
            console.log($window.scrollTop());
            $btnTop.hide();
            return;
        }

        $btnTop.show().stop().animate({
            top: ($window.scrollTop() + clientHeight/2 +90)
        });
    });
    $btnTop.find('a').on('click', function () {

        $('html,body').animate({
            scrollTop:0
        });
        return false;
    })
}


/**
 * 判断footer是否在页脚
 */
function autoFooter(){
    var viewHeight = document.documentElement.clientHeight,
        bodyHeight = $('body').height();
    if(viewHeight>bodyHeight){
        $('.footer').addClass('footerFix');
    }else{
        $('.footer').removeClass('footerFix');
    }
}

/*
* 倒计时
* */

function backTimer(ele,time){
    var time = time || 60,
        $ele = $(ele);
    if($ele.attr('isSending') === 'false'
       || !$ele.attr('isSending')){
        $ele.attr({
            isSending:true
        });
    var timer = setInterval(function () {
            if(time>0){
                $ele.text( -- time + 's后重新发送');
            }else{
                $ele.text('重新发送');
                $ele.attr({
                    isSending:false
                });
                clearInterval(timer);
            }
        },1000);
    }

}